Trò chơi xếp gạch đơn giản
7.081 lượt xem;
1 using UnityEngine;
2 using System.Collections;
3
4 public class BlockScript : MonoBehaviour {
5
6 // Use this for initialization
7 void Start ()
8 {
9 InitializeColor();
10 }
11
12 public void InitializeColor()
13 {
14 GetComponent<Renderer>().material.color = new Color(Random.Range(0.0f, 1.0f), Random.Range(0.0f, 1.0f), Random.Range(0.0f, 1.0f));
15 }
16
17
18 // Update is called once per frame
19 void Update () {
20
21 }
22
23 void OnCollisionExit2D(Collision2D col)
24 {
25 gameObject.SetActive(false);
26 GameManager.Score += 20;
27 GameManager.BlocksAlive--;
28 }
29 }
2 using System.Collections;
3
4 public class BlockScript : MonoBehaviour {
5
6 // Use this for initialization
7 void Start ()
8 {
9 InitializeColor();
10 }
11
12 public void InitializeColor()
13 {
14 GetComponent<Renderer>().material.color = new Color(Random.Range(0.0f, 1.0f), Random.Range(0.0f, 1.0f), Random.Range(0.0f, 1.0f));
15 }
16
17
18 // Update is called once per frame
19 void Update () {
20
21 }
22
23 void OnCollisionExit2D(Collision2D col)
24 {
25 gameObject.SetActive(false);
26 GameManager.Score += 20;
27 GameManager.BlocksAlive--;
28 }
29 }
Use this for initialization
Update is called once per frame